#include<iostream>
#include<cstdio>
using namespace std;
const int N=500005;
int n,sum,a[N],last[N],zz[N],l[N],r[N],rr[N];
int main()
{
	freopen("fruit.in","r",stdin);freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	a[0]=-1;r[0]=1;
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if (a[i]!=a[i-1])
		{
			last[sum]=i-1;
			zz[++sum]=i;
			l[sum]=sum-1;r[sum]=sum+1;
		}
		rr[i]=i+1;
	}
	last[sum]=n;
	while (r[0]!=sum+1)
	{
		int i=r[0];
		while (i!=sum+1)
		{
			printf("%d ",zz[i]);
			zz[i]=rr[zz[i]];
			i=r[i];
		}
		i=r[0];
		while (i!=sum+1)
		{
			if (zz[i]>last[i])
			{
				if (l[i]==0||r[i]==sum+1)
				{
					r[l[i]]=r[i];l[r[i]]=l[i];
				}
				else
				{	
					r[l[i]]=r[r[i]];l[r[r[i]]]=l[i];
					if (zz[r[i]]<=last[r[i]])rr[last[l[i]]]=zz[r[i]],last[l[i]]=last[r[i]];
					r[i]=r[r[i]];
				}
			}
			i=r[i];
		}
		printf("\n");
	}
	return 0;
}
